import Vue from 'vue'
import App from './App.vue'
import './registerServiceWorker'
import router from './router'
import store from './store'
import axios from 'axios'; 
import Vant from 'vant'
import 'vant/lib/index.css'
Vue.use(Vant);
Vue.config.productionTip = false

axios.defaults.baseURL = "/list"
// 全局路由守卫
router.beforeEach((to, from, next) => {
  //获取用户登录成功后储存的登录标志
  let userToken = localStorage.getItem('token');
  if (userToken) {
    next();
  } else {
    if (to.name === 'login' || to.name === 'Index' || to.name === 'Find' || to.name === 'Classify' || to.name === 'detail' || to.name === 'GoodsList') {
      next();
    } else {
      next('/login');
    }
  }
})

new Vue({
  router,
  store,
  render: h => h(App)
}).$mount('#app')